﻿Public Class frmClienteEstadoCuenta

    Dim controller As New ControllerSigeco.controller_ventas()

    Public Property lbCliente() As String
        Get
            Return lblCliente.Text
        End Get
        Set(ByVal value As String)
            lblCliente.Text = value
        End Set
    End Property


    Private _codCliente As Integer = 0
    Public Property codCliente() As Integer
        Get
            Return _codCliente
        End Get
        Set(ByVal value As Integer)
            _codCliente = value
        End Set
    End Property

    Private Sub frmClienteEstadoCuenta_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        dgAnterior.AutoGenerateColumns = False
        dgDatos.AutoGenerateColumns = False
        dgTotal.AutoGenerateColumns = False

        dtpFechaInicio.Value = New DateTime(DateTime.Now.Year, 1, 1, 0, 0, 0)
        dtpFechaFin.Value = DateTime.Now
        GenerarDatos()

    End Sub

    Private Sub GenerarDatos()

        Try

            If codCliente > 0 Then

                Dim dsDatos As New DataSet
                dsDatos = controller.get_Clientes_EstadoCuenta(oiml.dbConn, codCliente, dtpFechaInicio.Value, dtpFechaFin.Value)

                If Not dsDatos Is Nothing Then

                    If dsDatos.Tables.Count = 3 Then

                        dgAnterior.DataSource = dsDatos.Tables(0)
                        dgDatos.DataSource = dsDatos.Tables(1)
                        dgTotal.DataSource = dsDatos.Tables(2)

                    Else

                        dgDatos.DataSource = dsDatos.Tables(0)
                        dgTotal.DataSource = dsDatos.Tables(1)

                    End If

                End If

            End If

        Catch ex As Exception

        End Try
        
    End Sub


    Private Sub btnCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelar.Click
        Me.Close()
    End Sub

    Private Sub btnGenerar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerar.Click
        GenerarDatos()
    End Sub

    Private Sub btnImprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImprimir.Click

    End Sub

End Class